﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

namespace DAL
{
    public class ProductDAL
    {
        DBConnection conn = new DBConnection();
        public bool checkBarCode(string barCode)
        {
            return conn.checkExistedItem("SELECT * FROM Product WHERE Product.barCode = " + barCode);
        }

        public DataTable LoadOutOfQuantity()
        {
            string sql = "SELECT productId,barCode,proNameId,brandId ,unitId,unitPrice,expiredDate,"
            +"quantity,worth FROM Product where isShow='1' and quantity<10";
            return conn.loadData(sql);
        }
        public DataTable LoadOutOfDate()
        {
            string sql = "SELECT productId,barCode,proNameId,brandId ,unitId,unitPrice,expiredDate,"
            + "quantity,worth FROM Product where isShow='1' and "
            + "expiredDate between GETDATE()and DateAdd(DD,7,GETDATE() )";
            return conn.loadData(sql);
        }
    }
}
